package com.yipao.core.config;

import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
import cn.binarywang.wx.miniapp.config.WxMaConfig;
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * 微信运维端配置
 *
 * @author tianhao
 */
@Configuration
public class WxOperateConfig {


    @Resource
    private WxProperties properties;


    @Bean
    public WxMaConfig wxMaOperateConfig() {
        WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
        config.setAppid(properties.getOperateAppId());
        config.setSecret(properties.getOperateAppSecret());
        return config;
    }


    @Bean
    public WxMaService wxMaOperateService(WxMaConfig wxMaOperateConfig) {
        WxMaService service = new WxMaServiceImpl();
        service.setWxMaConfig(wxMaOperateConfig);
        return service;
    }
}
